home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / sendmail / sendmail-5.65c+IDA-1.4.4.1 / mailstats / RCS / mailstats.c,v next >
Encoding:
Text File  |  1991-06-26  |  3.1 KB  |  143 lines

  1. head    5.7;
  2. branch    5.7.0;
  3. access;
  4. symbols
  5.     UICSO:5.7.0
  6.     RELEASE:5.7.0.1
  7.     VANILLA:5.7;
  8. locks; strict;
  9. comment    @ * @;
  10.  
  11.  
  12. 5.7
  13. date    91.06.26.15.43.34;    author paul;    state Exp;
  14. branches
  15.     5.7.0.1;
  16. next    ;
  17.  
  18. 5.7.0.1
  19. date    91.06.26.15.50.30;    author paul;    state Exp;
  20. branches;
  21. next    ;
  22.  
  23.  
  24. desc
  25. @Print sendmail statistics.
  26. @
  27.  
  28.  
  29. 5.7
  30. log
  31. @5.65 distribution.
  32. @
  33. text
  34. @/*
  35.  * Copyright (c) 1983 Eric P. Allman
  36.  * Copyright (c) 1988 Regents of the University of California.
  37.  * All rights reserved.
  38.  *
  39.  * Redistribution and use in source and binary forms are permitted provided
  40.  * that: (1) source distributions retain this entire copyright notice and
  41.  * comment, and (2) distributions including binaries display the following
  42.  * acknowledgement:  ``This product includes software developed by the
  43.  * University of California, Berkeley and its contributors'' in the
  44.  * documentation or other materials provided with the distribution and in
  45.  * all advertising materials mentioning features or use of this software.
  46.  * Neither the name of the University nor the names of its contributors may
  47.  * be used to endorse or promote products derived from this software without
  48.  * specific prior written permission.
  49.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  50.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  51.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  52.  *
  53.  */
  54.  
  55. #ifndef lint
  56. char copyright[] =
  57. "@@(#) Copyright (c) 1988 Regents of the University of California.\n\
  58.  All rights reserved.\n";
  59. #endif /* not lint */
  60.  
  61. #ifndef lint
  62. static char sccsid[] = "@@(#)mailstats.c    5.7 (Berkeley) 6/1/90";
  63. #endif /* not lint */
  64.  
  65. #include <sys/file.h>
  66. #include <sendmail.h>
  67. #include <mailstats.h>
  68. #include "pathnames.h"
  69.  
  70. main(argc, argv)
  71.     int argc;
  72.     char **argv;
  73. {
  74.     extern char *optarg;
  75.     extern int optind;
  76.     struct statistics stat;
  77.     register int i;
  78.     int ch, fd;
  79.     char *sfile, *ctime();
  80.  
  81.     sfile = _PATH_MAILSTATS;
  82.     while ((ch = getopt(argc, argv, "f:")) != EOF)
  83.         switch((char)ch) {
  84.         case 'f':
  85.             sfile = optarg;
  86.             break;
  87.         case '?':
  88.         default:
  89.             fputs("usage: mailstats [-f file]\n", stderr);
  90.             exit(EX_USAGE);
  91.         }
  92.     argc -= optind;
  93.     argv += optind;
  94.  
  95.     if ((fd = open(sfile, O_RDONLY)) < 0) {
  96.         fputs("mailstats: ", stderr);
  97.         perror(sfile);
  98.         exit(EX_NOINPUT);
  99.     }
  100.     if (read(fd, &stat, sizeof(stat)) != sizeof(stat) ||
  101.         stat.stat_size != sizeof(stat)) {
  102.         fputs("mailstats: file size changed.\n", stderr);
  103.         exit(EX_OSERR);
  104.     }
  105.  
  106.     printf("Statistics from %s", ctime(&stat.stat_itime));
  107.     printf(" M msgsfr bytes_from  msgsto   bytes_to\n");
  108.     for (i = 0; i < MAXMAILERS; i++)
  109.         if (stat.stat_nf[i] || stat.stat_nt[i])
  110.             printf("%2d %6ld %10ldK %6ld %10ldK\n", i,
  111.                 stat.stat_nf[i], stat.stat_bf[i],
  112.                 stat.stat_nt[i], stat.stat_bt[i]);
  113.     exit(0);
  114. }
  115. @
  116.  
  117.  
  118. 5.7.0.1
  119. log
  120. @Portability improvements from Bruce Lilly.
  121. @
  122. text
  123. @a29 4
  124. static char  rcsid[] = "@@(#)$Id$";
  125. #ifdef    __GNUC__
  126. static    char    compiled[] = "@@(#)compiled by gcc version "__VERSION__;
  127. #endif
  128. a36 1
  129. int
  130. a46 2
  131.     int getopt();
  132.     void perror();
  133. d67 1
  134. a67 1
  135.     if (read(fd, (char *)&stat, sizeof(stat)) != sizeof(stat) ||
  136. d77 1
  137. a77 1
  138.             printf("%2d %6lu %10lu  %6lu %10lu\n", i,
  139. d80 1
  140. a80 1
  141.     return(0);
  142. @
  143.